package com.yl.auth.mapper;

import com.yl.auth.entity.User;
import com.yl.auth.entity.Users;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yl.auth.model.entity.Yuangong;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author W
 * @since 2023-07-24
 */
public interface UsersMapper extends BaseMapper<Users> {
    @Delete("delete from users where id=#{usersId}")
    void deletebyUid(Integer usersId);
    @Update("update users set password=#{yuangong.password},username=#{yuangong.account},type=3,imgurl=#{yuangong.avatar},name=#{yuangong.name},phone=#{yuangong.phone},idcard=#{yuangong.idcard} where id=#{yuangong.usersId}")
    void updateByUid(@Param("yuangong") Yuangong yuangong);

    Users getPrimId(@Param("id") Integer id);

    @Update("update from users username=#{username},password=#{password} where id=#{usersId}")
    void updateusers(@Param("id") Integer usersId);

    Users getZxPrimId(@Param("id") Integer id);
    @Select("select MAX(id) id from users")
    Integer getMax();

    Users getJiGouDuan(@Param("id") Integer id);

    Users getYuanGong(@Param("id") Integer id);
    @Delete("delete from user_role where user_id=#{yuangong.usersId}")
    void reomveRole(@Param("yuangong") Yuangong yuangong);
}
